/**
 * Towerhack logging
 * Provides log_<level> functions with a printf-like syntax.
 * Can output at 4 different log levels, to a file or stdout or both.
 * Output may contain the timestamp from the clock or the game time in
 * ticks or both.
 * log_init() must be called before any other log functions except
 * log_print_usage_and_exit, which will always work.
 */

#include <stdbool.h>

// max. characters in any log message, including '\0'
#define LOG_BUFFER_SIZE 4096

// max. characters in a log_fatal message which are drawn on the screen
#define LOG_SCREENMSG_SIZE 256

typedef enum {
	LOG_DEBUG,  // on-demand inserted debug messages
	LOG_INFO,   // general information
	LOG_ERROR,  // normal errors, usually from bad input
	LOG_FATAL,  // errors which cause program exit
	LOG_NOTHING // ignore all messages
} LogLevel;

extern LogLevel log_level;

extern bool log_to_file;
extern bool log_to_stderr;

void log_init (bool file_enabled, const char *filename, bool stderr_enabled,
               bool timestamp_enabled, bool ticks_enabled);
void log_cleanup ();

void log_debug (char* format, ...);
void log_info (char* format, ...);
void log_error (char* format, ...);

/**
 * Fatal level messages cause immediate program exit. This function
 * does not return. If Allegro is initialized and a graphics display
 * is available, the message is also displayed to the user.
 */
void log_fatal (char* format, ...);

/**
 * Prints a usage message to stderr and exit (exit_status).
 * This function is different for the server/client and thus
 * defined in {server,client}_util_log.c.
 * 
 * argv0: Name of this application, from argv[0]
 */
void log_print_usage_and_exit (const char* argv0, int exit_status);
